﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TCL.EO;
using TCL.FUNC;
using System.Configuration;

namespace TCL.DB
{
    public class DataAccessObject
    {
        public static List<ConnectionStringEO> lstConn;

        public String getConnectionString(String sName)
        {
            String sRet = "";
            if (!CheckEx.IsListObject<ConnectionStringEO>(lstConn))
            {
                lstConn = new List<ConnectionStringEO>();
                foreach (ConnectionStringSettings item in ConfigurationManager.ConnectionStrings)
                {
                    lstConn.Add(new ConnectionStringEO(item.Name, item.ConnectionString, item.ProviderName));
                }
            }
            if (CheckEx.IsListObject<ConnectionStringEO>(lstConn))
            {
                ConnectionStringEO objTemp = lstConn.Find(n => n.name.Equals(sName));
                if (CheckEx.IsObject(objTemp))
                    sRet = objTemp.connectionString;
            }
            return sRet;
        }
    }
}
